//
//  ActivityViewManager.m
//  WDFans
//
//  Created by Zhihong Yuan on 2/9/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ActivityViewManager.h"
#import "MBProgressHUD.h"

@implementation ActivityViewManager
+ (void)startedNetWorkActivityWithText:(NSString *)text
{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:[[UIApplication sharedApplication] delegate].window];
    hud.labelText = text;
    [[[UIApplication sharedApplication] delegate].window addSubview:hud];
    [hud show:YES];
    [hud release];
}
+ (void)stoppedNetWorkActivity
{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    [MBProgressHUD hideHUDForView:[[UIApplication sharedApplication] delegate].window animated:YES];
}

+ (void)showErrorViewWithMessage:(NSString *)message
{
    MBProgressHUD *hud = [[MBProgressHUD alloc] initWithView:[[UIApplication sharedApplication] delegate].window];
    hud.labelText = message;
    UIView *v = [[UIView alloc] init];
	v.backgroundColor = [UIColor clearColor];
	hud.customView = v;
	[v release];
    hud.mode = MBProgressHUDModeCustomView;
    [[[UIApplication sharedApplication] delegate].window addSubview:hud];
    [hud show:YES];
    [hud hide:YES afterDelay:1.f];
    [hud release];
}
@end
